﻿<div class="form-horizontal" ms-controller="XMGL">
    <div class="form-group">
        <label class="col-xs-2 control-label">项目状态</label>
        <div class="col-xs-4">
            <select class="form-control" ms-duplex="modelData.Status">
                <option value="0" ms-attr-selected="modelData.Status=='0'?'selected':''">正在进行</option>
                <option value="1" ms-attr-selected="modelData.Status=='1'?'selected':''">已结束</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-2 control-label">优先级</label>
        <div class="col-xs-4">
            <select class="form-control" ms-duplex="modelData.YXJ">
                <option>高</option>
                <option>中</option>
                <option>低</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-2 control-label">项目名称</label>
        <div class="col-xs-5">
            <input class="form-control " ms-duplex="modelData.XMMC" />
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-2 control-label">开始时间</label>
        <div class="col-xs-5">
            <input class="szhl_form_date form-control " ms-duplex="modelData.StartDate" />
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-2 control-label">结束时间</label>
        <div class="col-xs-5">
            <input class="szhl_form_date form-control " ms-duplex="modelData.EndDate" />
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-2 control-label">项目描述</label>
        <div class="col-xs-9">
            <textarea class="form-control   szhl_require" rows="5" ms-duplex="modelData.XMMS"></textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-2 control-label">项目进度</label>
        <div class="col-xs-5">
            <input class="form-control " ms-duplex="modelData.XMJD" />
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-2 control-label">负责人</label>
        <div class="col-xs-9">
            <input type="text" class="form-control szhl_getPeoples szhl_require" signle="Y" ms-duplex="modelData.XMFZR" />
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-2 control-label">参与人</label>
        <div class="col-xs-9">
            <input type="text" class="form-control szhl_getPeoples   szhl_require" ms-duplex="modelData.XMCYR">
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-2 control-label">附件</label>
        <div class="col-xs-9">
            <input type="text" value="" class="span2  szhl_Upload form-control" ms-duplex="modelData.Files" />
        </div>
    </div>
</div>
<script>
    var tempmodel = avalon.define({
        $id: "XMGL",
        name: "项目管理",

        modelData: (!pmodel.pageType && localStorage.getItem(pmodel.FormCode)) ? $.parseJSON(localStorage.getItem(pmodel.FormCode)) : { "Status": "0", "YXJ": "高", "XMMC": "", "StartDate": "", "EndDate": "", "XMFZR": ComFunJS.getnowuser(), "XMCYR": "", "XMMS": "", "XMJD": "0", "Files": "" },
        iswf: false,//是否属于流程表单
        inittemp: function (strId) {
            if (strId) {
                //编辑加载数据
                $.getJSON('/API/FTAPI.ashx?Action=GETXMGLMODEL', { P1: strId }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        tempmodel.modelData = resultData.Result;
                        if (tempmodel.modelData.StartDate && tempmodel.modelData.StartDate.length > 10) {
                            tempmodel.modelData.StartDate = tempmodel.modelData.StartDate.substring(0, 10);
                        }
                        if (tempmodel.modelData.EndDate && tempmodel.modelData.EndDate.length > 10) {
                            tempmodel.modelData.EndDate = tempmodel.modelData.EndDate.substring(0, 10);
                        }

                        setTimeout(" ComFunJS.initForm()", 500)
                    }
                })
            } else {
                ComFunJS.initForm()
            }
        },//初始化
        SaveData: function (btdom, piid) {
            var data = tempmodel.modelData.$model;
            var modelValue = JSON.stringify(data);
            $.post("/API/FTAPI.ashx?ACTION=ADDXMGL", { P1: modelValue }, function (result) {
                var jsonresult = $.parseJSON(result)
                btdom.removeClass("disabled").find("i").hide();
                if ($.trim(jsonresult.ErrorMsg) == "") {
                    ComFunJS.winsuccessnew("操作成功");
                }
            });
        },
    });
    tempmodel.$watch("modelData.*", function (a, b) {
        if (!tempmodel.modelData.ID) {
            localStorage.setItem(pmodel.FormCode, JSON.stringify(tempmodel.modelData.$model));
        }
    })
</script>